<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="/static/pear/component/pear/css/pear.css" />
</head>
<body>
<form class="layui-form">
    <div class="mainBox  layui-card-body" style="padding: 0 0;">
        <div class="main-container">
            <input type="hidden" name="courseid" value="{$inf.courseid}">
            <input type="hidden" name="type" value="{$type}">
            <input type="hidden" name="id" value="{$inf.id}">
            <div class="layui-form-item">
                <label class="layui-form-label">规则名称</label>
                <div class="layui-input-block" style="width: 60%;">
                    <input type="text" name="name" value="{$inf.name}" lay-verify="required" autocomplete="off" placeholder="请填写规则名称" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">服务年限</label>
                <div class="layui-input-block" style="width: 60%;display: flex">
                    <select name="services_year_select">
                        <option value=">" {eq name="$inf.services_year_select" value=">"}selected{/eq}>大于</option>
                        <option value="<" {eq name="$inf.services_year_select" value="<"}selected{/eq}>小于</option>
                        <option value="=" {eq name="$inf.services_year_select" value="="}selected{/eq}>等于</option>
                        <option value=">=" {eq name="$inf.services_year_select" value=">="}selected{/eq}>大于等于</option>
                        <option value="<=" {eq name="$inf.services_year_select" value="<="}selected{/eq}>小于等于</option>
                    </select>
                    <input type="text" name="services_year" value="{$inf.services_year}" id="services_year" autocomplete="off" placeholder="请填写服务年限" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">年龄</label>
                <div class="layui-input-block" style="width: 60%;display: flex">
                    <select name="age_select">
                        <option value=">" {eq name="$inf.age_select" value=">"}selected{/eq}>大于</option>
                        <option value="<" {eq name="$inf.age_select" value="<"}selected{/eq}>小于</option>
                        <option value="=" {eq name="$inf.age_select" value="="}selected{/eq}>等于</option>
                        <option value=">=" {eq name="$inf.age_select" value=">="}selected{/eq}>大于等于</option>
                        <option value="<=" {eq name="$inf.age_select" value="<="}selected{/eq}>小于等于</option>
                    </select>
                    <input type="text" name="age" value="{$inf.age}" id="age" autocomplete="off" placeholder="请填写年龄" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">下属人数</label>
                <div class="layui-input-block" style="width: 60%;display: flex">
                    <select name="xiashu_select">
                        <option value=">" {eq name="$inf.xiashu_select" value=">"}selected{/eq}>大于</option>
                        <option value="<" {eq name="$inf.xiashu_select" value="<"}selected{/eq}>小于</option>
                        <option value="=" {eq name="$inf.xiashu_select" value="="}selected{/eq}>等于</option>
                        <option value=">=" {eq name="$inf.xiashu_select" value=">="}selected{/eq}>大于等于</option>
                        <option value="<=" {eq name="$inf.xiashu_select" value="<="}selected{/eq}>小于等于</option>
                    </select>
                    <input type="text" name="xiashu" value="{$inf.xiashu}" id="xiashu" autocomplete="off" placeholder="请选择下属人数" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">Function</label>
                <div class="layui-input-block" style="width: 60%;display: flex">
                    <input type="text" id="function" name="function" value="{$inf.function}" autocomplete="off" placeholder="请选择Function" class="layui-input">
                    <a onclick="show_field('function', 'Function', '{$inf.courseid}', '{$inf.id}')" class="layui-btn">选择</a>
                    <a id="clear_function" class="layui-btn layui-btn-danger">清空</a>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">Position</label>
                <div class="layui-input-block" style="width: 60%;display: flex">
                    <input type="text" id="position" name="position" value="{$inf.position}" autocomplete="off" placeholder="请选择Position" class="layui-input">
                    <a onclick="show_field('position', 'Position', '{$inf.courseid}', '{$inf.id}')" class="layui-btn">选择</a>
                    <a id="clear_position" class="layui-btn layui-btn-danger">清空</a>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">Division</label>
                <div class="layui-input-block" style="width: 60%;display: flex">
                    <input type="text" id="division" name="division" value="{$inf.division}" autocomplete="off" placeholder="请选择Division" class="layui-input">
                    <a onclick="show_field('division', 'Division', '{$inf.courseid}', '{$inf.id}')" class="layui-btn">选择</a>
                    <a id="clear_division" class="layui-btn layui-btn-danger">清空</a>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">Division(MT)</label>
                <div class="layui-input-block" style="width: 60%;display: flex">
                    <input type="text" id="division_mt" name="division_mt" value="{$inf.division_mt}" autocomplete="off" placeholder="请选择Division(MT)" class="layui-input">
                    <a onclick="show_field('division_mt', 'Division(MT)', '{$inf.courseid}', '{$inf.id}')" class="layui-btn">选择</a>
                    <a id="clear_division_mt" class="layui-btn layui-btn-danger">清空</a>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">Entity</label>
                <div class="layui-input-block" style="width: 60%;display: flex">
                    <input type="text" id="entity" name="entity" value="{$inf.entity}" autocomplete="off" placeholder="请选择Entity" class="layui-input">
                    <a onclick="show_field('entity', 'Entity', '{$inf.courseid}', '{$inf.id}')" class="layui-btn">选择</a>
                    <a id="clear_entity" class="layui-btn layui-btn-danger">清空</a>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">Entity(MT)</label>
                <div class="layui-input-block" style="width: 60%;display: flex">
                    <input type="text" id="entity_mt" name="entity_mt" value="{$inf.entity_mt}" autocomplete="off" placeholder="请选择Entity(MT)" class="layui-input">
                    <a onclick="show_field('entity_mt', 'Entity(MT)', '{$inf.courseid}', '{$inf.id}')" class="layui-btn">选择</a>
                    <a id="clear_entity_mt" class="layui-btn layui-btn-danger">清空</a>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">Activity Sector</label>
                <div class="layui-input-block" style="width: 60%;display: flex">
                    <input type="text" id="activity_sector" name="activity_sector" value="{$inf.activity_sector}" autocomplete="off" placeholder="请选择Activity Sector" class="layui-input">
                    <a onclick="show_field('activity_sector', 'Activity Sector', '{$inf.courseid}', '{$inf.id}')" class="layui-btn">选择</a>
                    <a id="clear_activity_sector" class="layui-btn layui-btn-danger">清空</a>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">Department</label>
                <div class="layui-input-block" style="width: 60%;display: flex">
                    <input type="text" id="department_name" name="department_name" value="{$inf.department_name}" autocomplete="off" placeholder="请选择Department" class="layui-input">
                    <a onclick="show_field('department_name', 'Department', '{$inf.courseid}', '{$inf.id}')" class="layui-btn">选择</a>
                    <a id="clear_department_name" class="layui-btn layui-btn-danger">清空</a>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">Region</label>
                <div class="layui-input-block" style="width: 60%;display: flex">
                    <input type="text" id="region" name="region" autocomplete="off" value="{$inf.region}" placeholder="请选择Region" class="layui-input">
                    <a onclick="show_field('region', 'Region', '{$inf.courseid}', '{$inf.id}')" class="layui-btn">选择</a>
                    <a id="clear_region" class="layui-btn layui-btn-danger">清空</a>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">Office Location</label>
                <div class="layui-input-block" style="width: 60%;display: flex">
                    <input type="text" id="office_location" name="office_location" value="{$inf.office_location}" autocomplete="off" placeholder="请选择Office Location" class="layui-input">
                    <a onclick="show_field('office_location', 'Office Location', '{$inf.courseid}', '{$inf.id}')" class="layui-btn">选择</a>
                    <a id="clear_office_location" class="layui-btn layui-btn-danger">清空</a>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">Nationality</label>
                <div class="layui-input-block" style="width: 60%;display: flex">
                    <input type="text" id="nationality" name="nationality" value="{$inf.nationality}" autocomplete="off" placeholder="请选择Nationality" class="layui-input">
                    <a onclick="show_field('nationality', 'Nationality', '{$inf.courseid}', '{$inf.id}')" class="layui-btn">选择</a>
                    <a id="clear_nationality" class="layui-btn layui-btn-danger">清空</a>
                </div>
            </div>
            {:token_field()}
        </div>
    </div>


    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
{include file="_Fragment/javascript" /}
<script src="/static/common/jquery-3.6.0.min.js"></script>
<script>

    $('#clear_function').click(function() {
        $('#function').val('');
    });

    $('#clear_position').click(function() {
        $('#position').val('');
    });

    $('#clear_division').click(function() {
        $('#division').val('');
    });

    $('#clear_division_mt').click(function() {
        $('#division_mt').val('');
    });

    $('#clear_activity_sector').click(function() {
        $('#activity_sector').val('');
    });
    $('#clear_entity').click(function() {
        $('#entity').val('');
    });
    $('#clear_entity_mt').click(function() {
        $('#entity_mt').val('');
    });
    $('#clear_department_name').click(function() {
        $('#department_name').val('');
    });
    $('#clear_region').click(function() {
        $('#region').val('');
    });
    $('#clear_office_location').click(function() {
        $('#office_location').val('');
    });

    $('#clear_nationality').click(function() {
        $('#nationality').val('');
    });

    layui.use(['form', 'jquery', 'element'], function() {
        let form = layui.form;
        let $ = layui.jquery;


        form.on('submit(user-save)', function(data) {
            let loading = layer.load();
            $.ajax({
                url: '/Course/modifyRules',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function(result) {
                    layer.close(loading);
                    if (result.status == 0) {
                        layer.msg(result.msg, {
                            icon: 1,
                            time: 1000
                        }, function() {
                            parent.layer.close(parent.layer.getFrameIndex(window
                                .name)); //关闭当前页
                            parent.layui.table.reload("user-table");
                        });
                    } else {
                        layer.msg(result.msg, {
                            icon: 2,
                            time: 1000
                        });
                    }
                }
            })
            return false;
        });
    })

    function show_field(field, title, courseid, rule_id) {
        layer.open({
            type: 2,
            title: title,
            shade: 0.1,
            area: ['800px', '500px'],
            content: '/Course/showField?type='+field+'&courseid='+courseid+'&rule_id='+rule_id
        });
    }
</script>
<script>
</script>
</body>
</html>